package z.sample.persistence.entity;

import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Entity
@Table(name = "employees")
@Cacheable
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
public class Employee {
	private Long id;
	private String lastName;
	private String firstName;
	private String extension;
	private String email;
	private Office office;
	private Employee reportTo;
	private String jobTitle;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "employeeNumber", unique = true, nullable = false)
	public Long getId() {
		return id;
	}

	@Column(name = "lastName", nullable = false)
	public String getLastName() {
		return lastName;
	}

	@Column(name = "firstName", nullable = false)
	public String getFirstName() {
		return firstName;
	}

	@Column(name = "extension", nullable = false)
	public String getExtension() {
		return extension;
	}

	@Column(name = "email", nullable = false)
	public String getEmail() {
		return email;
	}

	@ManyToOne
	@JoinColumn(name = "officeCode", nullable = false)
	public Office getOffice() {
		return office;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "reportsTo")
	public Employee getReportTo() {
		return reportTo;
	}

	@Column(name = "jobTitle", nullable = false)
	public String getJobTitle() {
		return jobTitle;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public void setExtension(String extension) {
		this.extension = extension;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public void setOffice(Office office) {
		this.office = office;
	}

	public void setReportTo(Employee reportTo) {
		this.reportTo = reportTo;
	}

	public void setJobTitle(String jobTitle) {
		this.jobTitle = jobTitle;
	}
}
